  # SPDX-License-Identifier: BSD-3-Clause
# Copyright(c) 2010-2014 Intel Corporation

# binary name
APP = cjson_demo
HOME=..
PWD:= $(shell pwd)
SRCDIR:=$(PWD)

#set compiler
CC = gcc
#CC = /home/circles/mydir/tools/gcc-linaro-6.3.1-2017.05-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-gcc

# all source are stored in SRCS-y
SRCS-y := main.c
SRCS-y += cJSON.c
#SRCS-y += cmdmain.c
#SRCS-y += commands.c

#src path
#VPATH += $(SRCDIR)/comm/src  $(SRCDIR)/net/src  $(SRCDIR)/net/src/bb $(SRCDIR)/net/src/pb $(SRCDIR)/net/src/rbs  $(SRCDIR)/proc/src $(SRCDIR)/net/src/app  $(SRCDIR)/net/src/yq $(SRCDIR)/dev/gpio/src  $(SRCDIR)/dev/scan/src $(SRCDIR)/dev/rs485/src $(SRCDIR)/dev/gps/src $(SRCDIR)/usockets $(SRCDIR)/usockets/eventing $(SRCDIR)/usockets/crypto 
VPATH += $(SRCDIR)/src  
#inc path
#CFLAGS += -I$(SRCDIR)/inc  -I$(SRCDIR)/comm/inc  -I$(SRCDIR)/net/inc  -I$(SRCDIR)/proc/inc -I$(SRCDIR)/dev/gpio/inc  -I$(SRCDIR)/dev/scan/inc -I$(SRCDIR)/dev/rs485/inc -I$(SRCDIR)/dev/gps/inc -I$(SRCDIR)/usockets -I$(SRCDIR)/usockets/internal -I/usr/local/include
CFLAGS += -I$(SRCDIR)/include
CFLAGS += -g -O0
CFLAGS += -Wall
#CFLAGS += -DLIBUS_NO_SSL
CFLAGS +=  -fgnu89-inline
LDFLAGS  := -L$(SRCDIR)/libs -lzlog -L/usr/local/lib -lpthread -lm 
OBJS := $(patsubst %.c,build/%.o,$(SRCS-y))

build/%.o: %.c Makefile  | build
	$(CC) $(CFLAGS) -c $< -o $@

build/$(APP): $(OBJS)
	$(CC) $(OBJS) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC) 
	cp build/$(APP) bin/

clean:
	rm -f build/$(APP)* build/*.o
	rm -f bin/$(APP)
    
pkg:
	tar -cvf zds_mcc.tar bin cfg log
